package Week4.J0509;

import java.util.Arrays;
import java.util.Scanner;

public class 数组变换 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] arr = new long[n];
        boolean flag = true;

        arr[0] = scanner.nextLong();

        for (int i = 1; i < arr.length; i++) {
            arr[i] = scanner.nextLong();
            if (arr[i-1] != arr[i]) {
                flag = false;
            }
        }

        if (flag) {
            System.out.println("YES");
            return;
        }

        Arrays.sort(arr);
        long max = arr[n - 1];

        for (int i = 0; i < n - 1; i++) {
            if (max % arr[i] == 0 && (max / arr[i]) % 2 == 0) {
                continue;
            }
            System.out.println("NO");
            return;
        }
        System.out.println("YES");
    }
}
